﻿namespace HySoft.Cash.Business
{
    using Huayou.Common.Database;
    using Huayou.Utils;
    using HySoft.Cash.BaseClass;
    using HySoft.Cash.DB;
    using HySoft.Cash.Structure;
    using System;
    using System.Data;
    using System.Web.UI;

    public class TbankinfoBN : BaseBusiness
    {
        private TbankinfoDB db;

        public TbankinfoBN(Page page)
            : base(page)
        {
            this.db = null;
            this.db = new TbankinfoDB(base.curDBOperater);
        }

        public TbankinfoBN(Page page, DBOperate oper)
            : base(page, oper)
        {
            this.db = null;
            this.db = new TbankinfoDB(base.curDBOperater);
        }

        public bool Add(TbankinfoDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Add(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public int AddId(TbankinfoDT detail)
        {
            int num = 0;

            try
            {
                num = this.db.AddId(detail);
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return num;
        }

        public bool Delete(int Sid)
        {
            bool flag = false;

            try
            {
                flag = this.db.Delete(Sid);
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return flag;
        }

        public void Dispose()
        {
            base.Dispose();
            if (this.db != null)
            {
                this.db = null;
            }
        }

        public bool Edit(TbankinfoDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Edit(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
                //
            }
            return flag;
        }

        public TbankinfoDT Get(int Sid)
        {
            TbankinfoDT odt = null;
            try
            {
                try
                {
                    odt = this.db.Get(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return odt;
        }

        public DataTable GetList()
        {
            base.DBFieldList = "Sid,EmpSid,BankName,Branch,AccountName,AccountNum,Bsb,PayReference";
            base.DBTable = "tBankInfo";
            return base.CommonGetList();
        }

        public void QueryAccountName(string AccountName)
        {
            if ((AccountName != null) && (AccountName.Trim() != ""))
            {
                base.Filter = "AccountName like '%" + StringUtils.ToSQL(AccountName) + "%'";
            }
        }

        public void QueryAccountNum(string AccountNum)
        {
            if ((AccountNum != null) && (AccountNum.Trim() != ""))
            {
                base.Filter = "AccountNum like '%" + StringUtils.ToSQL(AccountNum) + "%'";
            }
        }

        public void QueryBankName(string BankName)
        {
            if ((BankName != null) && (BankName.Trim() != ""))
            {
                base.Filter = "BankName like '%" + StringUtils.ToSQL(BankName) + "%'";
            }
        }

        public void QueryBranch(string Branch)
        {
            if ((Branch != null) && (Branch.Trim() != ""))
            {
                base.Filter = "Branch like '%" + StringUtils.ToSQL(Branch) + "%'";
            }
        }

        public void QueryBsb(string Bsb)
        {
            if ((Bsb != null) && (Bsb.Trim() != ""))
            {
                base.Filter = "Bsb like '%" + StringUtils.ToSQL(Bsb) + "%'";
            }
        }

        public void QueryEmpSid(int EmpSid)
        {
            base.Filter = "EmpSid= " + EmpSid;
        }

        public void QueryPayReference(string PayReference)
        {
            if ((PayReference != null) && (PayReference.Trim() != ""))
            {
                base.Filter = "PayReference like '%" + StringUtils.ToSQL(PayReference) + "%'";
            }
        }

        public void QuerySid(int Sid)
        {
            base.Filter = "Sid= " + Sid;
        }
    }
}

